package com.ruoyi.cm.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.common.utils.BigDecimalUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;

import java.math.BigDecimal;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 合同建设场景对象 cm_bs_contract_info_scene
 *
 * @author zxs
 * @date 2025-03-11
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("cm_bs_contract_info_scene")
public class CmBsContractInfoScene extends BaseEntity {

    private static final long serialVersionUID=1L;

    /**
     * 主键id
     */
    @TableId(value = "id")
    private Long id;
    /**
     * 合同id
     */
    private Long contractId;
    /**
     * 建设场景名称
     */
    private String sceneName;
    /**
     * 容量
     */
    private BigDecimal capacity;
    private void setCapacity(BigDecimal capacity){
        if(capacity == null){
            this.capacity = BigDecimal.ZERO;
            return;
        }
        this.capacity = new BigDecimal(capacity.toPlainString()).setScale(2,BigDecimal.ROUND_HALF_UP);
    }
    private BigDecimal chgCapacity;
    private void setChgCapacity(BigDecimal chgCapacity){
        if(chgCapacity == null){
            this.chgCapacity = BigDecimal.ZERO;
            return;
        }
        this.chgCapacity = new BigDecimal(chgCapacity.toPlainString()).setScale(2,BigDecimal.ROUND_HALF_UP);
    }
    /**
     * 单价
     */
    private BigDecimal price;
    private void setPrice(BigDecimal price){
        this.price = BigDecimalUtil.stpTrailZero(price);
    }

    /**
     * 合同备注
     */
    private String remark;
    /**
     * 是否删除
     */
    @TableLogic
    private String delFlag;

    // 变更单价
    private BigDecimal chgPrice;
    // 变更hou单价
    private BigDecimal chgedPrice;


//    public void setChgPrice(BigDecimal chgPrice) {
//        if(ObjectUtils.isEmpty(this.chgPrice)){
//            this.chgPrice = BigDecimal.ZERO;
//        } else {
//            this.chgPrice = new BigDecimal(chgPrice.toPlainString()).setScale(2,BigDecimal.ROUND_HALF_UP);
//        }
//    }
//
//    public void setChgedPrice(BigDecimal chgedPrice) {
//        if(ObjectUtils.isEmpty(this.chgedPrice)){
//            this.chgedPrice = BigDecimal.ZERO;
//        } else {
//            this.chgedPrice = new BigDecimal(chgedPrice.toPlainString()).setScale(2,BigDecimal.ROUND_HALF_UP);
//        }
//    }

    public BigDecimal getChgPrice() {
        if (chgPrice == null) {
            return BigDecimal.ZERO;
        }
        return new BigDecimal(chgPrice.toPlainString()).setScale(2,BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getChgedPrice() {
        if (chgedPrice == null) {
            return BigDecimal.ZERO;
        }
        return new BigDecimal(chgedPrice.toPlainString()).setScale(2,BigDecimal.ROUND_HALF_UP);
    }
}
